﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Surface.Core;
using Microsoft.Surface.Core.Manipulations;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;


namespace SurfaceApplication3
{
    class TowerManager
    {
        private Texture2D tower_top;
        private Texture2D tower_bottom;
        private List<Tower> towers = new List<Tower>();
        public void add_tower(Vector2 position)
        {
            towers.Add(new Tower(tower_top,tower_bottom,position));
        }
        public void update(ReadOnlyContactCollection currentContacts)
        {
            foreach(Tower tower in towers){
                tower.update(currentContacts);
            }
        }

        public void add_contact(Contact contact, List<int> possessed)
        {
            foreach (Tower tower in towers)
            {
                if (contact.IsFingerRecognized && tower.belongs(contact))
                {
                    tower.add_contact(contact);
                    possessed.Add(contact.Id);
                    break;
                }
            }
        }

        public void trow_bullet(BulletManager bullet_manager)
        {
            foreach (Tower tower in towers)
            {
                tower.trow_bullet(bullet_manager);
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (Tower tower in towers)
            {
                tower.Draw(spriteBatch);
            }
        }

        public void LoadContent(ContentManager Content)
        {
            foreach (Tower tower in towers)
            {
                tower.LoadContent(Content);
            }
        }
    }
}
